Datascience para el Bien Social
  • Home
  • Categories
  • Tags
  • Archives

Visualizando la tendencia de hombres y mujeres a la hora de elegir estudios.

Visualizando la tendencia de hombres y mujeres a la hora de elegir estudios.¶

  • En este proyecto vamos a ver cuales son las carreras que prefieren hombres y mujeres, si existen diferencias y si existe algo caracteristico.
In [8]:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt

women_degrees = pd.read_csv('https://raw.githubusercontent.com/bokeh/bokeh/master/bokeh/sampledata/percent-bachelors-degrees-women-usa.csv')
cb_dark_blue = (0/255,107/255,164/255)
cb_orange = (255/255, 128/255, 14/255)
stem_cats = ['Engineering', 'Computer Science', 'Psychology', 'Biology', 'Physical Sciences', 'Math and Statistics']

print(women_degrees.head(3))
   Year  Agriculture  Architecture  Art and Performance    Biology   Business  \
0  1970     4.229798     11.921005                 59.7  29.088363   9.064439   
1  1971     5.452797     12.003106                 59.9  29.394403   9.503187   
2  1972     7.420710     13.214594                 60.4  29.810221  10.558962   

   Communications and Journalism  Computer Science  Education  Engineering  \
0                           35.3              13.6  74.535328          0.8   
1                           35.5              13.6  74.149204          1.0   
2                           36.6              14.9  73.554520          1.2   

     English  Foreign Languages  Health Professions  Math and Statistics  \
0  65.570923               73.8                77.1                 38.0   
1  64.556485               73.9                75.5                 39.0   
2  63.664263               74.6                76.9                 40.2   

   Physical Sciences  Psychology  Public Administration  \
0               13.8        44.4                   68.4   
1               14.9        46.2                   65.5   
2               14.8        47.6                   62.6   

   Social Sciences and History  
0                         36.8  
1                         36.2  
2                         36.1  
In [9]:
fig = plt.figure(figsize=(18, 3))

for sp in range(0,6):
    ax = fig.add_subplot(1,6,sp+1)
    ax.plot(women_degrees['Year'], women_degrees[stem_cats[sp]], c=cb_dark_blue, label='Women', linewidth=3)
    ax.plot(women_degrees['Year'], 100-women_degrees[stem_cats[sp]], c=cb_orange, label='Men', linewidth=3)
    ax.spines["right"].set_visible(False)    
    ax.spines["left"].set_visible(False)
    ax.spines["top"].set_visible(False)    
    ax.spines["bottom"].set_visible(False)
    ax.set_xlim(1968, 2011)
    ax.set_ylim(0,100)
    ax.set_title(stem_cats[sp])
    ax.tick_params(bottom="off", top="off", left="off", right="off")
    
    if sp == 0:
        ax.text(2005, 87, 'Men')
        ax.text(2002, 8, 'Women')
    elif sp == 5:
        ax.text(2005, 62, 'Men')
        ax.text(2001, 35, 'Women')
plt.show()
In [11]:
#Data for this plots
stem_cats = ['Psychology', 'Biology', 'Math and Statistics', 'Physical Sciences', 'Computer Science', 'Engineering', 'Computer Science']
lib_arts_cats = ['Foreign Languages', 'English', 'Communications and Journalism', 'Art and Performance', 'Social Sciences and History']
other_cats = ['Health Professions', 'Public Administration', 'Education', 'Agriculture','Business', 'Architecture']


fig = plt.figure(figsize=(16, 16))
count_stem = 0
count_lib_arts = 0
count_other = 0

#First column, STEM degrees
for sp in range(0, 18, 3):
    ax = fig.add_subplot(6, 3, sp+1)
    ax.plot(women_degrees['Year'], women_degrees[stem_cats[count_stem]], c=cb_dark_blue, label="Women", linewidth=3)
    ax.plot(women_degrees['Year'], 100-women_degrees[stem_cats[count_stem]], c= cb_orange, label="Men", linewidth=3)
    ax.set_xlim(1970, 2010)
    ax.set_ylim(0, 100)
    ax.set_title(stem_cats[count_stem])
    ax.tick_params(bottom = "off", left = "off", top = "off", right = "off")
    ax.spines["right"].set_visible(False)    
    ax.spines["left"].set_visible(False)
    ax.spines["top"].set_visible(False)    
    ax.spines["bottom"].set_visible(False)
    ax.tick_params(labelbottom='off')
    ax.set_yticks([0, 100])
    ax.axhline(50, c=(171/255, 171/255, 171/255), alpha = 0.3)
    if count_stem == 0:
        ax.text(2006, 80, "Women")
        ax.text(2006, 10, "Men")
    if count_stem == 5:
        ax.text(2006, 90, "Women")
        ax.text(2006, 25, "Men")
        ax.tick_params(labelbottom='on')
    count_stem += 1
    

#Second Column. Liberal Arts.
for sp in range(1, 16, 3):
    ax = fig.add_subplot(6, 3, sp+1)
    ax.plot(women_degrees['Year'], women_degrees[lib_arts_cats[count_lib_arts]], c=cb_dark_blue, label="Women", linewidth=3)
    ax.plot(women_degrees['Year'], 100-women_degrees[lib_arts_cats[count_lib_arts]], c=cb_orange, label="Men", linewidth=3)
    ax.set_xlim(1970, 2010)
    ax.set_ylim(0, 100)
    ax.set_title(lib_arts_cats[count_lib_arts])
    ax.tick_params(bottom = "off", left = "off", top = "off", right = "off")
    ax.spines["right"].set_visible(False)    
    ax.spines["left"].set_visible(False)
    ax.spines["top"].set_visible(False)    
    ax.spines["bottom"].set_visible(False)
    ax.tick_params(labelbottom='off')
    ax.set_yticks([0, 100])
    ax.axhline(50, c=(171/255, 171/255, 171/255), alpha = 0.3)
    if count_lib_arts == 0:
        ax.text(2006, 80, "Women")
        ax.text(2006, 10, "Men")
    if count_lib_arts == 4:
        ax.text(2006, 90, "Women")
        ax.text(2006, 25, "Men")
        ax.tick_params(labelbottom='on')
    
    count_lib_arts += 1

#Third Column. Other cats.
for sp in range(2, 20, 3):
    ax = fig.add_subplot(6, 3, sp+1)
    ax.plot(women_degrees['Year'], women_degrees[other_cats[count_other]], c=cb_dark_blue, label = "Women", linewidth = 3)
    ax.plot(women_degrees['Year'], 100-women_degrees[other_cats[count_other]], c=cb_orange, label = "Men", linewidth = 3)    
    ax.set_xlim(1970, 2010)
    ax.set_ylim(0, 100)
    ax.set_title(other_cats[count_other])
    ax.tick_params(bottom = "off", left = "off", top = "off", right = "off")
    ax.spines["right"].set_visible(False)    
    ax.spines["left"].set_visible(False)
    ax.spines["top"].set_visible(False)    
    ax.spines["bottom"].set_visible(False)
    ax.tick_params(labelbottom='off')
    ax.set_yticks([0, 100])
    ax.axhline(50, c=(171/255, 171/255, 171/255), alpha = 0.3)
    if count_other == 0:
        ax.text(2006, 90, "Women")
        ax.text(2006, 4, "Men")
    if count_other == 5:
        ax.text(2006, 80, "Women")
        ax.text(2006, 25, "Men")
        ax.tick_params(labelbottom='on')
    
    
    count_other += 1
        
plt.savefig("gender_degrees.png")
plt.show()
In [ ]:
 

Published

ago. 8, 2017

Category

Data Visualization

Tags

  • data visualization 5
  • matplotlib 5
  • python 10

Stay in Touch

Get Monthly Updates

  • Powered by Pelican. Theme: Elegant by Talha Mansoor